package com.appbee.core.client.data;

import com.google.gwt.view.client.Range;

/**
 * Utility class for range
 * 
 * @author jakobmarrunarsson
 * 
 */
public class RangeWrap
{
	private final Range wrappedRange;

	public RangeWrap(Range range)
	{
		super();
		this.wrappedRange = range;
	}

	public boolean contains(Range range)
	{
		if (this.wrappedRange == null || range == null)
			return false;
		int wEnd = wrappedRange.getStart() + wrappedRange.getLength();
		int end = range.getStart() + range.getLength();
		return wrappedRange.getStart() <= range.getStart() && wEnd >= end;
	}

	public boolean contains(int index)
	{
		if (this.wrappedRange == null)
			return false;
		int wEnd = wrappedRange.getStart() + wrappedRange.getLength();
		return wrappedRange.getStart() <= index && wEnd > index;
	}
}
